//
//  JMMainViewController.m
//  VoluntaryStar
//
//  Created by ios on 15/8/17.
//  Copyright (c) 2015年 ios. All rights reserved.
//

#import "JMMainViewController.h"
#import "JMBrowserViewController.h"
#import "JMOutLookView.h"
#import "JMWheelView.h"
#import "JMRotationView.h"
#import "JMRotationItem.h"

#import "JMPersonViewController.h" // ge ren xin xi

#import "JMOrdinaryViewController.h" //普通
#import "JMAutonomyViewController.h"//zi zhu
#import "JMArtViewController.h" //yi ti
#import "JMCurveWreckerViewController.h"//xue ba
#import "JMSummerCampViewController.h"//xia ling ying
#import "JMCharacterViewController.h"// xingge



@class AppDelegate;

@interface JMMainViewController ()<UITextFieldDelegate,JMWheelViewDelegate,JMRotationViewDelegate,UIAlertViewDelegate>

@property (nonatomic,strong) UIImageView *backImageView;
@property (nonatomic,strong) JMOutLookView *outLookView;

@property (nonatomic,strong) JMWheelView *wheelView;

@property (nonatomic,strong) JMRotationView *roationView;



@end

@implementation JMMainViewController

#pragma mark  初始化基本界面参数 和  数据参数

-(UIImageView *)backImageView{
    if(!_backImageView){
        _backImageView = [[UIImageView alloc]init];
        _backImageView.backgroundColor = [UIColor clearColor];
        _backImageView.image = [UIImage imageNamed:@"ship.bundle/main_backImage"];
        _backImageView.frame = CGRectMake(0, 0, UI_SCREEN_WITH, UI_SCREEN_HEIGHT);
    }
    return _backImageView;
}

-(JMOutLookView *)outLookView{
    if(!_outLookView){
        _outLookView = [[JMOutLookView alloc]init];
        if(iphone4){
            _outLookView.frame = CGRectMake(0, 20, UI_SCREEN_WITH, UI_SCREEN_WITH * 0.600875);
        }else{
            _outLookView.frame = CGRectMake(0, 20, UI_SCREEN_WITH, UI_SCREEN_WITH * 0.671875);
        }
        _outLookView.imageView.image = [UIImage imageNamed:@"projectImage.bundle/main_test"];
        _outLookView.backgroundColor = [UIColor clearColor];
    }
    return _outLookView;
}

-(JMWheelView *)wheelView{
    if(!_wheelView){
        _wheelView = [[JMWheelView alloc]initWithFrame:CGRectMake(UI_SCREEN_WITH *0.09375, UI_SCREEN_HEIGHT - UI_SCREEN_WITH * 0.78025  * 0.5384,UI_SCREEN_WITH * 0.8125 , UI_SCREEN_WITH *0.8125)];
        _wheelView.backgroundColor = [UIColor clearColor];
        _wheelView.delegate =self;
    }
    return _wheelView;
}

-(JMRotationView *)roationView{
    if(!_roationView){
        _roationView = [[JMRotationView alloc]initWithFrame:CGRectMake(UI_SCREEN_WITH *0.04375, self.outLookView.frameBottom - 2, UI_SCREEN_WITH - UI_SCREEN_WITH *0.04375 *2, UI_SCREEN_HEIGHT - self.outLookView.frameHeight - self.wheelView.frameHeight/2.0 - 30)];
        _roationView.backgroundColor = [UIColor clearColor];
        _roationView.deleagte =self;
    }
    return _roationView;
}

#pragma mark   主界面的启动开始
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:YES];
    self.backBtn.hidden =YES;
    self.navBackBtn.hidden =YES;
    self.navigationController.navigationBarHidden = YES;
    [self.navigationController setToolbarHidden:YES animated:NO];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:self.backImageView];
    [self.view addSubview:self.roationView];
    [self.view addSubview:self.outLookView];
    [self.view addSubview:self.wheelView];
    
    NSMutableArray *array = [[NSMutableArray alloc]initWithCapacity:0];
    NSArray * titleArray = @[@"志愿指导",@"自主招生",@"艺体考生",@"知识闯关",@"夏令营",@"性格测试"];;
    for(int i = 0;i < 6;i++){
        JMRotationItem *item = [[JMRotationItem alloc]init];
        item.title = [titleArray objectAtIndex:i];
        item.image = [UIImage imageNamed:[NSString stringWithFormat:@"ship.bundle/mainIcon/main_Icon_%d",i]];
        [array addObject:item];
    }
    [self.roationView setRotationItem:array];
}
#pragma mark 相关代理方法
-(void)centerButtonClick:(JMWheelView *)selfView{
    
    JMPersonViewController *vc =[JMPersonViewController new];
    JMNavigationController *nav = [[JMNavigationController alloc]initWithRootViewController:vc];
    [self presentViewController:nav animated:YES completion:^{
        
    }];
}

-(void)rotationViewButtonClick:(RotationViewItemType)newtype{
    if(newtype == RotationViewItemPuTongKaoSheng){
        JMOrdinaryViewController *vc = [JMOrdinaryViewController new];
        [self.navigationController pushViewController:vc animated:YES];
    }else if (newtype == RotationViewItemZiZhuZhaoSheng){
//        JMAutonomyViewController *vc =[JMAutonomyViewController new];
//        [self.navigationController pushViewController:vc animated:YES];
        UIAlertView *alerView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"已签约北京大学、..等全国15家重点高校!你的大学你做主！敬请期待V2.0" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK ", nil];
        [alerView show];
    }else if (newtype == RotationViewItemYiTiKaoSheng){
        UIAlertView *alerView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"首都师范大学科德学院指定培训基地，敬请期待V2.0" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK ", nil];
        [alerView show];
//        JMArtViewController *vc = [JMArtViewController new];
//        [self.navigationController pushViewController:vc animated:YES];
    }else if (newtype == RotationViewItemWoShiXueBa){
        UIAlertView *alerView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"此功能在v1.0未开通，将会在v2.0开通，敬请关注" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK ", nil];
        [alerView show];
        
//        JMCurveWreckerViewController *vc = [JMCurveWreckerViewController new];
//        [self.navigationController pushViewController:vc animated:YES];
    }else if (newtype == RotationViewItemXiaLingYing){
//        JMSummerCampViewController *vc = [JMSummerCampViewController new];
//        [self.navigationController pushViewController:vc animated:YES];
        UIAlertView *alerView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"北京大学招生夏令营指定报名入口，敬请期待V2.0" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK ", nil];
        [alerView show];
        

    }else if (newtype == RotationViewItemXingGeCeShi){
        JMCharacterViewController *vc = [JMCharacterViewController new];
        [self.navigationController pushViewController:vc animated:YES];
    }
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    
}
#pragma mark  界面的 代理方法
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end

